package com.itfenghuang.day15;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/*
客户端发送数据并接收回送消息
 */
public class A03_Client {
    public static void main(String[] args) throws IOException {
//        创建Socket对象
        Socket sk = new Socket("127.0.0.1", 12233);
//        获取输入流对象
        InputStream is = sk.getInputStream();
//        获取输出流对象
        OutputStream os = sk.getOutputStream();
        os.write("僵小鱼是小僵尸吗".getBytes());
        byte[] bys = new byte[1024];
        int len = is.read(bys);
        System.out.println(new String(bys,0,len));

        sk.close();

    }
}
